
package com.epam.android.training.level1.rss;

import com.epam.android.training.level1.UniqueEntity;

import android.util.Log;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @author Anton Novikov
 */
public class ItemBo implements UniqueEntity {

  private static final String TAG = "ItemBo";

  private long id;

  private long feedId;

  private String title;

  private String description;

  private URL link;

  private Date pubDate;

  private boolean isRead;

  /**
   * Creates an instance of ItemBo.
   */
  public ItemBo() {}

  @Override
  public long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }

  public long getFeedId() {
    return feedId;
  }

  public void setFeedId(long feedId) {
    this.feedId = feedId;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public URL getLink() {
    return link;
  }

  public void setLink(URL link) {
    this.link = link;
  }

  public void setLink(String link) {
    try {
      this.link = new URL(link);
    } catch (MalformedURLException e) {
      Log.e(TAG, "Unable to parse item link", e);
    }
  }

  public Date getPubDate() {
    return pubDate;
  }

  public void setPubDate(Date pubDate) {
    this.pubDate = pubDate;
  }

  public boolean isRead() {
    return isRead;
  }

  public void setRead(boolean isRead) {
    this.isRead = isRead;
  }

  public void setRead(int isRead) {
    this.isRead = isRead == 1 ? true : false;
  }
}
